//
//  ViewAlert+Block.m
//  QuHuWai
//
//  Created by wzkj on 14-10-20.
//  Copyright (c) 2014年 Wzkj. All rights reserved.
//

#import "UIAlertView+Block.h"
#import <objc/runtime.h>
static char UIAlertView_key_clicked='a';
@implementation UIAlertView (Block)

-(void) handlerClickedButton:(void (^)(NSInteger btnIndex))aBlock{
    self.delegate = self;
    objc_setAssociatedObject(self, &UIAlertView_key_clicked, aBlock, OBJC_ASSOCIATION_COPY);
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    void (^block)(NSInteger btnIndex) = objc_getAssociatedObject(self, &UIAlertView_key_clicked);
    if (block) {
       block(buttonIndex);
    }
}
@end
